/* PersistenceFactory.java
 *
 * @author Team D, B
 * @date 28.05.2008
 *
 * persistence factory
 */
package ocumed.teams;

/**
 * create the persistence handler for both teams
 *
 * @author Willi
 * @author Daniel Rudigier
 */
public abstract class PersistenceFactory  {
    private static IPersistence instance = null;

    /**
     * return a implementation for the persistence
     * using a singleton
     * 
     * @return the persistence handler
     */
    public static IPersistence getInstance() {
        if (instance == null) {
            try {
                instance = (IPersistence) Class.forName("ocumed.persistence.PersistenceFacade").newInstance();
            } catch (Exception e1) {
                try {
                    instance = (IPersistence) Class.forName("ocumed.persistenz.mapper.PersistenceHandler").newInstance();
                } catch (Exception e2) {
                    System.out.println("persitence handler could not be instantiated.");
                    // fehler von team d ausgeben
                    e1.printStackTrace();
                }
            }
        }
        return instance;
    }
}
